﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BISPOS.Repository;
namespace BISPOS
{
    public partial class StockUserControl : UserControl
    {
        private Stock stock;
        private StockRepository stockRepository = new StockRepository();
        public StockUserControl(int id)
        {

            InitializeComponent();
            stock = stockRepository.GetStock(id);
            
            dateTextEdit.Text = stock.Date.ToShortDateString();
            if(stock.BillItems.Count != 0)
            {
                billIdTextEdit.Text= stock.BillItems.FirstOrDefault().Bill.Id.ToString().PadLeft(5,'0');
                supplierTextEdit.Text = stock.BillItems.FirstOrDefault().Bill.Supplier.Name;
            }else{
                billIdTextEdit.Text = "ขายล่วงหน้า";
                billIdTextEdit.Text = "ขายล่วงหน้า";
            }

            originalQuantityTextEdit.Text = stock.OriginalQuantity.ToString("N2");
            currentQuantityTextEdit.Text = stock.CurrentQuantity.ToString("N2");


            
        }
    }
}
